//
//  AnimationSegmentBar.m
//  fengshui
//
//  Created by huliang on 13-4-2.
//
//

#import "AnimationSegmentBar.h"

@implementation AnimationSegmentBar

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
    }
    return self;
}


-(AnimationSegmentBar *)initWithTitlesAndActions:(NSArray *)titleArr Actions:(NSArray *)actionArr frame:(CGRect)rect{
        
    AnimationSegmentBar *animateSeg = [[[AnimationSegmentBar alloc] initWithFrame:rect] autorelease];
    UIButton *tmpBtn;
    NSArray *tmpArr;
    int btnWidth = (rect.size.width/[titleArr count] );
    for(int i=0; i<[titleArr count]; i++){
        tmpArr = [[NSBundle mainBundle] loadNibNamed:@"AnimationSegmentBar" owner:self options:nil];
        tmpBtn = [tmpArr objectAtIndex:1];
        [tmpBtn setTitle:[titleArr objectAtIndex:i] forState:UIControlStateNormal];
        [tmpBtn setFrame:CGRectMake( btnWidth*i, 0, btnWidth , rect.size.height)];
        [tmpBtn addTarget:self action:@selector(selectedBtnAtIndex:) forControlEvents:UIControlEventTouchUpInside];
        tmpBtn.tag = i + 1000;
    }
    
    return animateSeg;
}



@end
